using DG.Tweening;
using NL.UIEffects;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using static UnityEngine.GraphicsBuffer;

namespace NL.SpriteAnimation
{
    public class SpriteMaterial_Dissolve : SpriteDotweenBase
    {
        Image Owner;
        float _OldFactor;

        Tweener _Animer;
        public float From=0,To=1;


        protected override void OnWakeup()
        {
            base.OnWakeup();
            Owner =WHO.GetComponentInChildren<Image>();
            if(Owner != null && Owner.material!=null)
                Owner.material.SetFloat("_DissolveAmount", From);
        }
        protected override void OnLive()
        {
            base.OnLive();

            if (Owner == null) return;

            if (_Animer != null && _Animer.IsPlaying()) _Animer.Kill();
            _Animer = Owner.material.DOFactor_DissolveAmount(To, Duration).SetDelay(Delay).SetEase(EaseType);
        }
    }
}

